package com.rupertjones.globalcron.web;

import com.rupertjones.globalcron.domain.Setting;

import static org.apache.commons.lang.StringUtils.isEmpty;

/**
 * <p>&copy Rupert Jones 2012</p>
 *
 * @author rup
 */
public class FormUser {

    private String password;
    private String confirmPassword;
    private Setting passwordPolicy;

    public FormUser(Setting setting) {
        this.passwordPolicy = setting;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getConfirmPassword() {
        return confirmPassword;
    }

    public void setConfirmPassword(String confirmPassword) {
        this.confirmPassword = confirmPassword;
    }

    public boolean isPasswordPolicyCompliant() {
        return !isEmpty(password) && password.matches(passwordPolicy.getValue());
    }

    public boolean isPasswordMatch() {
        return !isEmpty(password) && password.equals(confirmPassword);
    }
}
